package io.github.doc.config.state;

import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import io.github.doc.config.PluginSetting;
import org.jetbrains.annotations.NotNull;


/**
 * <p>Company: 深圳振瀚信息技术有限公司成都分公司 </p>
 * <p>Description: </p>
 *
 * @author ZH.Team
 * @version 1.0.0
 * @email "mailto:ZH.Team@zhxx.com"
 * @date 2025.01.04 13:26
 * @since y.y.y
 */
@State(
        name = "org.intellij.sdk.settings.PluginSettingsState",
        storages = @Storage("PluginSettings.xml")
)
public class PluginSettingsState implements PersistentStateComponent<PluginSetting> {


    /**
     * Plugin setting
     */
    private PluginSetting pluginSetting = new PluginSetting();

    /**
     * Gets instance *
     *
     * @return the instance
     * @since y.y.y
     */
    public static PluginSettingsState getInstance() {
        return ApplicationManager.getApplication().getService(PluginSettingsState.class);
    }

    /**
     * Gets state *
     *
     * @return the state
     * @since y.y.y
     */
    @Override
    public PluginSetting getState() {
        return this.pluginSetting;
    }

    /**
     * Load state
     *
     * @param pluginSetting plugin setting
     * @since y.y.y
     */
    @Override
    public void loadState(@NotNull PluginSetting pluginSetting) {
        this.pluginSetting = pluginSetting;
    }
}
